package com.tdkj.action.backstage.decorate;

import java.util.List;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.decorate.BeanDecorate;
import com.tdkj.model.decorate.BeanDecorateType;
import com.tdkj.service.decorate.IBeanDecorateService;


public class DecorateAction extends BaseAction {
    
	private IBeanDecorateService decorateService;
	
	private List<BeanDecorate> decorates ;
	
	private BeanDecorate decorate ;
	
	private List<BeanDecorateType> types;
	
	public String execute() {
		types = decorateService.findAll(BeanDecorateType.class);
		decorates = decorateService.findAll(BeanDecorate.class);
		return "success";
	}
	
	public String add() {
		decorateService.save(decorate);
		return execute();
	}
	
	public String update() {
		decorateService.saveOrUpdate(decorate, BeanDecorate.class);
		return execute();
	}

	public String delete() {
		decorateService.delete(decorate.getId(), BeanDecorate.class);
		return execute();
	}
	
	public String edit() {
		types = decorateService.findAll(BeanDecorateType.class);
		decorate = decorateService.findById(decorate.getId(), BeanDecorate.class);
		return "edit";
	}

	public List<BeanDecorate> getDecorates() {
		return decorates;
	}

	public void setDecorates(List<BeanDecorate> decorates) {
		this.decorates = decorates;
	}

	public BeanDecorate getDecorate() {
		return decorate;
	}

	public void setDecorate(BeanDecorate decorate) {
		this.decorate = decorate;
	}

	@Resource
	public void setDecorateService(IBeanDecorateService decorateService) {
		this.decorateService = decorateService;
	}

	public List<BeanDecorateType> getTypes() {
		return types;
	}

	public void setTypes(List<BeanDecorateType> types) {
		this.types = types;
	}
	
	
	
}
